package aeemqx

import (
	"context"
	"devops-super/internal/consts"
	"github.com/gogf/gf/v2/text/gstr"
	"strings"
)

// $SYS/brokers/3c974c59b00e@172.17.0.6/clients/qc_lora_gw_01/disconnected
func (s *sAeemqx) IsDeviceConnectTopic(ctx context.Context, topic string) bool {
	return strings.HasSuffix(topic, "/connected")
}
func (s *sAeemqx) IsDeviceDisConnectTopic(ctx context.Context, topic string) bool {
	return strings.HasSuffix(topic, "/disconnected")
}

func (s *sAeemqx) IsDeviceMochiConnectTopic(ctx context.Context, topic string) bool {
	return strings.Contains(topic, consts.MOCHI_MQTT_DEVICE_ON)
}
func (s *sAeemqx) IsDeviceMochiDisConnectTopic(ctx context.Context, topic string) bool {
	return strings.Contains(topic, consts.MOCHI_MQTT_DEVICE_OFF)
}

func (s *sAeemqx) IsDevicePubTopic(ctx context.Context, topic string) bool {
	return gstr.Contains(topic, consts.EMQX_TOPIC_PUB)
}

func (s *sAeemqx) IsMobileAppPubTopic(ctx context.Context, topic string) bool {
	return gstr.Contains(topic, consts.EMQX_TOPIC_AppPub)
}
